﻿using System;
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{

    class _taperfortoolshanksformanualchanging
    {
        public static void taperfortoolshanksformanualchanging(Dictionary<string, Object> data)//细柄丝锥
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            refin.Linetype = Linetype.Dashed;
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中心线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            centre.Linetype = Linetype.DashDot;
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //参数
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            double scale = 1; //放大系数

            double czc = Convert.ToDouble(data["czc"]);
           // double czc = 30;

            double D1 = 31.75;
            double z = 0.4;
            double L = 68.4;
            double l1 = 48.4;
            double d1 = 17.4;
            double p = 3;
            double d3 = 16.5;
            double y = 1.6;
            double b = 16.1;
            double t = Convert.ToDouble(data["t"]);
            double d2 = 13;
            double d4 = Convert.ToDouble(data["d4"]);
            double g = 12;
            double l2 = Convert.ToDouble(data["l2"]);
            double l3 = Convert.ToDouble(data["l3"]);
            double l4 = 62.9;
            double l5 = 5.5;
            double D = 50;
            double i = 9.6;
            double K = 8;
            double D4 = Convert.ToDouble(data["dconms"]);
            double tg = 0.291667;

            if (czc == 30)
            {
                D1 = 31.75;
                L = 68.4;
                l1 = 48.4;
                d1 = 17.4;
                p = 3;
                d3 = 16.5;
                y = 1.6;
                b = 16.1;
                d2 = 13;
                g = 12;
                l4 = 62.9;
                l5 = 5.5;
                i = 9.6;
                D = 50;
                K = 8;
            }

            if (czc == 40)
            {
                D1 = 44.45;
                L = 93.4;
                l1 = 65.4;
                d1 = 25.3;
                p = 5;
                d3 = 24;
                y = 1.6;
                b = 16.1;
                d2 = 17;
                g = 16;
                l4 = 85.2;
                l5 = 8.2;
                i = 11.6;
                D = 63;
                K = 10;
            }
            if(czc == 45)
            {
                D1 = 57.15;
                L = 106.8;
                l1 = 82.8;
                d1 = 32.4;
                p = 6;
                d3 = 30;
                y = 3.2;
                b = 19.3;
                d2 = 21;
                g = 20;
                l4 = 96.8;
                l5 = 10;
                i = 15.2;
                D = 80;
                K = 12;
            }
            if (czc == 50)
            {
                D1 = 69.85;
                L = 126.8;
                l1 = 101.8;
                d1 = 39.6;
                p = 8;
                d3 = 38;
                y = 3.2;
                b = 25.7;
                d2 = 26;
                g = 24;
                l4 = 115.3;
                l5 = 11.5;
                i = 15.2;
                D = 97.5;
                K = 12;
            }
            if (czc == 60)
            {
                D1 = 107.95;
                L = 206.8;
                l1 = 161.8;
                d1 = 60.2;
                p = 10;
                d3 = 58;
                y = 3.2;
                b = 225.7;
                d2 = 32;
                g = 30;
                l4 = 192.8;
                l5 = 14;
                i = 19.2;
                D = 156;
                K = 16;
            }
            if (czc == 65)
            {
                D1 = 133.35;
                L = 246;
                l1 = 202;
                d1 = 75;
                p = 12;
                d3 = 72;
                y = 4;
                b = 32.4;
                d2 = 38;
                g = 36;
                l4 = 230;
                l5 = 16;
                i = 22;
                D = 195;
                K = 18;
            }
            if (czc == 70)
            {
                D1 = 165.1;
                L = 296;
                l1 = 252;
                d1 = 92;
                p = 14;
                d3 = 90;
                y = 4;
                b = 32.4;
                d2 = 38;
                g = 36;
                l4 = 280;
                l5 = 16;
                i = 24;
                D = 230;
                K = 20;
            }
            if (czc == 75)
            {
                D1 = 203.2;
                L = 370;
                l1 = 307;
                d1 = 114;
                p = 16;
                d3 = 110;
                y = 5;
                b = 40.5;
                d2 = 50;
                g = 48;
                l4 = 350;
                l5 = 20;
                i = 27;
                D = 280;
                K = 22;
            }
            if (czc == 80)
            {
                D1 = 254;
                L = 469;
                l1 = 394;
                d1 = 140;
                p = 18;
                d3 = 136;
                y = 6;
                b = 40.5;
                d2 = 50;
                g = 48;
                l4 = 449;
                l5 = 20;
                i = 34;
                D = 350;
                K = 28;
            }

            Vector2 v1 = new Vector2(0, 0);
            Vector2 v2 = new Vector2(v1.X + L + i + K * 2 + 6, v1.Y);
            Vector2 v3 = new Vector2(v2.X - i - K * 2 - 3 + z, v1.Y);
            Vector2 v4 = new Vector2(v3.X, v3.Y + D1 / 2);
            Vector2 v5 = new Vector2(v4.X - z, v3.Y + D1 / 2 - (z * tg) / 2);
            Vector2 v6 = new Vector2(v5.X - l1, v3.Y + D1 / 2 - (z + l1) * tg / 2);
            Vector2 v7 = new Vector2(v6.X, v3.Y + d3 / 2);
            Vector2 v8 = new Vector2(v7.X - p, v7.Y);
            Vector2 v9 = new Vector2(v8.X, v3.Y + d1 / 2);
            Vector2 v10 = new Vector2(v5.X - L, v9.Y);
            Vector2 v11 = new Vector2(v4.X, v4.Y * -1);
            Vector2 v12 = new Vector2(v5.X, v5.Y * -1);
            Vector2 v13 = new Vector2(v6.X, v6.Y * -1);
            Vector2 v14 = new Vector2(v7.X, v7.Y * -1);
            Vector2 v15 = new Vector2(v8.X, v8.Y * -1);
            Vector2 v16 = new Vector2(v9.X, v9.Y * -1);
            Vector2 v17 = new Vector2(v10.X, v10.Y * -1);
            Vector2 v18 = new Vector2(v3.X, v3.Y + D1 / 2.3369);
            Vector2 v19 = new Vector2(v5.X + i - K, v18.Y);
            Vector2 v20 = new Vector2(v19.X, v3.Y + D / 2);
            Vector2 v21 = new Vector2(v20.X + K, v20.Y);
            Vector2 v22 = new Vector2(v21.X, v3.Y + D4 / 2);
            Vector2 v23 = new Vector2(v22.X + K * 2, v22.Y);
            Vector2 v24 = new Vector2(v23.X, v23.Y - D4 / 3);
            Vector2 v25 = new Vector2(v24.X, v24.Y * -1);
            Vector2 v26 = new Vector2(v23.X, v23.Y * -1);
            Vector2 v27 = new Vector2(v22.X, v22.Y * -1);
            Vector2 v28 = new Vector2(v21.X, v21.Y * -1);
            Vector2 v29 = new Vector2(v20.X, v20.Y * -1);
            Vector2 v30 = new Vector2(v19.X, v19.Y * -1);
            Vector2 v31 = new Vector2(v18.X, v18.Y * -1);
            Vector2 v32 = new Vector2(v19.X, v3.Y + t);
            Vector2 v33 = new Vector2(v21.X, v32.Y);
            Vector2 v34 = new Vector2(v32.X, v32.Y * -1);
            Vector2 v35 = new Vector2(v33.X, v33.Y * -1);
            Vector2 v50 = new Vector2(v10.X, v3.Y + d4 / 2);
            Vector2 v36 = new Vector2(v50.X + (d4 - d2) / 4 / Math.Tan(60 * pi / 180), v3.Y + d2 / 2 + (d4 - d2) / 4);
            Vector2 v37 = new Vector2(v36.X + (d2 / 2 + (d4 - d2) / 4 - d2 / 2) / Math.Tan(30 * pi / 180), v3.Y + d2 / 2);
            Vector2 v38 = new Vector2(v10.X + l5, v37.Y);
            Vector2 v39 = new Vector2(v38.X, v3.Y + g / 2);
            Vector2 v40 = new Vector2(v39.X + (g / 2 - g / 2.69) / 2, v3.Y + g / 2.69);
            Vector2 v41 = new Vector2(v10.X + l3, v40.Y);
            Vector2 v42 = new Vector2(v41.X + g / 2.69, v3.Y);
            Vector2 v43 = new Vector2(v50.X, v50.Y * -1);
            Vector2 v44 = new Vector2(v36.X, v36.Y * -1);
            Vector2 v45 = new Vector2(v37.X, v37.Y * -1);
            Vector2 v46 = new Vector2(v38.X, v38.Y * -1);
            Vector2 v47 = new Vector2(v39.X, v39.Y * -1);
            Vector2 v48 = new Vector2(v40.X, v40.Y * -1);
            Vector2 v49 = new Vector2(v41.X, v41.Y * -1);
            Vector2 v51 = new Vector2(v10.X + l2, v39.Y);
            Vector2 v52 = new Vector2(v51.X, v51.Y * -1);
            Vector2 v53 = new Vector2(v42.X, v3.Y + v6.Y + (v42.X - v6.X) * tg / 2);
            Vector2 v54 = new Vector2(v53.X + l1 / 27.27, v3.Y + v53.Y / 2);
            Vector2 v55 = new Vector2(v54.X, v54.Y * -1);
            Vector2 v56 = new Vector2(v53.X, v53.Y * -1);

            Vector2 v57 = new Vector2(v1.X - D, v1.Y);
            Vector2 v58 = new Vector2(v57.X - D - 6, v1.Y);
            Vector2 v59 = new Vector2(v57.X - D / 2 - 3, v57.Y);
            Vector2 v60 = new Vector2(v59.X, v59.Y + D / 2 + 3);
            Vector2 v61 = new Vector2(v60.X, v60.Y * -1);
            Vector2 v62 = new Vector2(v59.X - b / 2, v59.Y + t);
            Vector2 v63 = new Vector2(v62.X + b, v62.Y);
            Vector2 v64 = new Vector2(v63.X, v59.Y + Math.Sqrt(Math.Pow(D / 2, 2) - Math.Pow(v63.X - v59.X, 2)));
            Vector2 v65 = new Vector2(v59.X + D / 2, v59.Y);
            Vector2 v66 = new Vector2(v64.X, v64.Y * -1);
            Vector2 v67 = new Vector2(v63.X, v63.Y * -1);
            Vector2 v68 = new Vector2(v62.X, v62.Y * -1);
            Vector2 v69 = new Vector2(v68.X, v66.Y);
            Vector2 v70 = new Vector2(v59.X - D / 2, v59.Y);
            Vector2 v71 = new Vector2(v62.X, v64.Y);



            //作图
            Line line1 = new Line(v1, v2);
            line1.Layer = centre;
            line1.Linetype = Linetype.DashDot;
            line1.LinetypeScale = 3;
            dxf.AddEntity(line1);

            LwPolyline line2 = new LwPolyline();
            line2.Vertexes.Add(new LwPolylineVertex(v4));
            line2.Vertexes.Add(new LwPolylineVertex(v5));
            line2.Vertexes.Add(new LwPolylineVertex(v6));
            line2.Vertexes.Add(new LwPolylineVertex(v7));
            line2.Vertexes.Add(new LwPolylineVertex(v8));
            line2.Vertexes.Add(new LwPolylineVertex(v9));
            line2.Vertexes.Add(new LwPolylineVertex(v10));
            line2.Vertexes.Add(new LwPolylineVertex(v17));
            line2.Vertexes.Add(new LwPolylineVertex(v16));
            line2.Vertexes.Add(new LwPolylineVertex(v15));
            line2.Vertexes.Add(new LwPolylineVertex(v14));
            line2.Vertexes.Add(new LwPolylineVertex(v13));
            line2.Vertexes.Add(new LwPolylineVertex(v12));
            line2.Vertexes.Add(new LwPolylineVertex(v11));
            line2.Vertexes.Add(new LwPolylineVertex(v4));
            fun.PolyFill(dxf, line2, 0.2, contour);

            LwPolyline line3 = new LwPolyline();
            line3.Vertexes.Add(new LwPolylineVertex(v19));
            line3.Vertexes.Add(new LwPolylineVertex(v30));
            line3.Vertexes.Add(new LwPolylineVertex(v31));
            line3.Vertexes.Add(new LwPolylineVertex(v18));
            line3.Vertexes.Add(new LwPolylineVertex(v19));
            line3.Vertexes.Add(new LwPolylineVertex(v20));
            line3.Vertexes.Add(new LwPolylineVertex(v21));
            line3.Vertexes.Add(new LwPolylineVertex(v28));
            line3.Vertexes.Add(new LwPolylineVertex(v29));
            line3.Vertexes.Add(new LwPolylineVertex(v19));
            fun.PolyFill(dxf, line3, 0.2, contour);

            LwPolyline line4 = new LwPolyline();
            line4.Vertexes.Add(new LwPolylineVertex(v22));
            line4.Vertexes.Add(new LwPolylineVertex(v23));
            line4.Vertexes.Add(new LwPolylineVertex(v24));
            line4.Vertexes.Add(new LwPolylineVertex(v25));
            line4.Vertexes.Add(new LwPolylineVertex(v26));
            line4.Vertexes.Add(new LwPolylineVertex(v27));
            line4.Vertexes[1].Bulge = Math.Tan(40 * pi / 180 / 4);
            line4.Vertexes[2].Bulge = Math.Tan(-58 * pi / 180 / 4);
            line4.Vertexes[3].Bulge = Math.Tan(40 * pi / 180 / 4);
            fun.PolyFill(dxf, line4, 0.2, contour);

            Line line5 = new Line(v32, v33);
            line5.Layer = refin;
            line5.Linetype = Linetype.Dashed;
            line5.LinetypeScale = 3;
            dxf.AddEntity(line5);

            Line line6 = new Line(v34, v35);
            line6.Layer = refin;
            line6.Linetype = Linetype.Dashed;
            line6.LinetypeScale = 3;
            dxf.AddEntity(line6);

            LwPolyline line7 = new LwPolyline();
            line7.Vertexes.Add(new LwPolylineVertex(v50));
            line7.Vertexes.Add(new LwPolylineVertex(v36));
            line7.Vertexes.Add(new LwPolylineVertex(v37));
            line7.Vertexes.Add(new LwPolylineVertex(v38));
            line7.Vertexes.Add(new LwPolylineVertex(v39));
            line7.Vertexes.Add(new LwPolylineVertex(v40));
            line7.Vertexes.Add(new LwPolylineVertex(v41));
            line7.Vertexes.Add(new LwPolylineVertex(v42));
            line7.Vertexes.Add(new LwPolylineVertex(v49));
            line7.Vertexes.Add(new LwPolylineVertex(v48));
            line7.Vertexes.Add(new LwPolylineVertex(v47));
            line7.Vertexes.Add(new LwPolylineVertex(v46));
            line7.Vertexes.Add(new LwPolylineVertex(v45));
            line7.Vertexes.Add(new LwPolylineVertex(v44));
            line7.Vertexes.Add(new LwPolylineVertex(v43));
            fun.PolyFill(dxf, line7, 0.2, contour);

            LwPolyline line8 = new LwPolyline();
            line8.Vertexes.Add(new LwPolylineVertex(v36));
            line8.Vertexes.Add(new LwPolylineVertex(v44));
            line8.Vertexes.Add(new LwPolylineVertex(v45));
            line8.Vertexes.Add(new LwPolylineVertex(v37));
            line8.Vertexes.Add(new LwPolylineVertex(v38));
            line8.Vertexes.Add(new LwPolylineVertex(v46));
            line8.Vertexes.Add(new LwPolylineVertex(v47));
            line8.Vertexes.Add(new LwPolylineVertex(v48));
            line8.Vertexes.Add(new LwPolylineVertex(v40));
            line8.Vertexes.Add(new LwPolylineVertex(v41));
            line8.Vertexes.Add(new LwPolylineVertex(v49));
            fun.PolyFill(dxf, line8, 0.2, contour);

            LwPolyline line9 = new LwPolyline();
            line9.Vertexes.Add(new LwPolylineVertex(v39));
            line9.Vertexes.Add(new LwPolylineVertex(v51));
            line9.Vertexes.Add(new LwPolylineVertex(v52));
            line9.Vertexes.Add(new LwPolylineVertex(v47));
            fun.PolyFill(dxf, line9, 0.2, contour);

            LwPolyline line10 = new LwPolyline();
            line10.Vertexes.Add(new LwPolylineVertex(v53));
            line10.Vertexes.Add(new LwPolylineVertex(v54));
            line10.Vertexes.Add(new LwPolylineVertex(v55));
            line10.Vertexes.Add(new LwPolylineVertex(v56));
            line10.Vertexes[0].Bulge = Math.Tan(18 * pi / 180 / 4);
            line10.Vertexes[1].Bulge = Math.Tan(-34 * pi / 180 / 4);
            line10.Vertexes[2].Bulge = Math.Tan(18 * pi / 180 / 4);
            fun.PolyFill(dxf, line10, 0.2, contour);

            //2

            fun.drawcircle(dxf, v59, d1 / 2, 0.2, contour);

            LwPolyline line11 = new LwPolyline();
            line11.Vertexes.Add(new LwPolylineVertex(v71));
            line11.Vertexes.Add(new LwPolylineVertex(v62));
            line11.Vertexes.Add(new LwPolylineVertex(v63));
            line11.Vertexes.Add(new LwPolylineVertex(v64));
            fun.PolyFill(dxf, line11, 0.2, contour);

            LwPolyline line12 = new LwPolyline();
            line12.Vertexes.Add(new LwPolylineVertex(v69));
            line12.Vertexes.Add(new LwPolylineVertex(v68));
            line12.Vertexes.Add(new LwPolylineVertex(v67));
            line12.Vertexes.Add(new LwPolylineVertex(v66));
            fun.PolyFill(dxf, line12, 0.2, contour);

            Arc c1 = fun.DrawArc3(v66, v65, v64);
            fun.drawBArc(dxf, c1, 0.2, contour);

            Arc c2 = fun.DrawArc3(v71, v70, v69);
            fun.drawBArc(dxf, c2, 0.2, contour);

            Line line13 = new Line(v60, v61);
            line13.Layer = centre;
            line13.Linetype = Linetype.DashDot;
            line13.LinetypeScale = 3;
            dxf.AddEntity(line13);

            Line line14 = new Line(v58, v57);
            line14.Layer = centre;
            line14.Linetype = Linetype.DashDot;
            line14.LinetypeScale = 3;
            dxf.AddEntity(line14);



            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v54));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v55));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v56));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v13));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v14));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v15));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v16));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v17));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v43));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v44));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v45));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v46));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v47));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v48));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v49));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v42));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v41));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v40));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v39));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v38));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v37));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v36));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v50));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v10));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v53));
            hatchpoly1.Vertexes[0].Bulge = Math.Tan(18 * pi / 180 / 4);
            hatchpoly1.Vertexes[1].Bulge = Math.Tan(-34 * pi / 180 / 4);
            hatchpoly1.Vertexes[2].Bulge = Math.Tan(18 * pi / 180 / 4);
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            Arc[] harc1 = new Arc[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int I = 0; I < hnumst1; I++)
            {
                htype1[I] = hatchpoly1.Explode()[I].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[I] == "Line")
                {
                    hline1[I] = (Line)hatchpoly1.Explode()[I];
                }
                if (htype1[I] == "Arc")
                {
                    harc1[I] = (Arc)hatchpoly1.Explode()[I];
                }
            }
            fun.hatchsub1(dxf, htype1, hnumst1, 45, 10, hline1, harc1, hatching);

            //标注

            double height = 5;
            double arrowsize = 1;
            double exline = 2;




            fun.dimrot1(dxf, v13, v12, 180, D1/2, 1, height, arrowsize, exline, "l1=" + l1, "", "");

            fun.dimrot1(dxf, v16, v13, 180, D1/2+(v16.Y +v13.Y )/2-(v13.Y +v12.Y )/2, 1, height, arrowsize, exline, "P=" + p, "", "");

            fun.dimrot1(dxf, v12, v30, 180, D1 / 2 - (v13.Y + v12.Y) / 2+(v12.Y +v30.Y )/2, 1, height, arrowsize, exline, "y=" + y, "", "");

            fun.dimrot1(dxf, v43, v46, 180, D1, 1, height, arrowsize, exline, "l5=" + l5, "", "");

            fun.dimrot1(dxf, v12, v46, 180, D1-(v43.Y +v46.Y )/2+(v12.Y +v46.Y )/2, 1, height, arrowsize, exline, "l4=" + l4, "", "");

            fun.dimrot1(dxf, v17, v12, 180, D1*1.5, 1, height, arrowsize, exline, "L=" + L, "", "");

            fun.dimrot1(dxf, v37, v45, 90, D/3, 1, height, arrowsize, exline, "d2=" + d2, "", "");

            fun.dimrot1(dxf, v10, v17, 90, D / 2, 1, height, arrowsize, exline, "d1=" + d1, "", "");

            fun.dimrot1(dxf, v10, v51, 0, D / 2, 1, height, arrowsize, exline, "l2=" + l2, "", "");

            fun.dimrot1(dxf, v10, v41, 0, D, 1, height, arrowsize, exline, "l3=" + l3, "", "");

            fun.dimrot1(dxf, v5, v12, 90, 0, 1, height, arrowsize, exline, "D1=" + D1, "", "");

            fun.dimrot1(dxf, v66, v69, 180, D1*1.5+(v69.Y +v66.Y )/2-(v17.Y +v12.Y )/2, 1, height, arrowsize, exline, "b=" + b, "", "");

            fun.dimrot1(dxf, v59, v69, 90, D/4, 1, height, arrowsize, exline, "t=" + t, "", "");

            fun.dimrot1(dxf, v20, v21, 0, K, 1, height, arrowsize, exline, "K=" + K, "", "");

            fun.dimrot1(dxf, v23, v26, -90, K, 1, height, arrowsize, exline, "D4=" + D4, "", "");

            fun.dimrot1(dxf, v28, v21, -90, K*6, 1, height, arrowsize, exline, "D=" + D, "", "");

            fun.dimrot1(dxf, v12, v28, 180, D1 * 1.5 - (v17.Y +v12.Y )/2+(v12.Y +v28.Y )/2, 1, height, arrowsize, exline, "i=" + i, "", "");




            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            Vector2 p0 = new Vector2(0, 0);

            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }





            //定义格式，路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);


        }

}
}